﻿using System;
using System.Collections.Generic;
using ContractManager.Entity;
using Speed.Data;

namespace ContractManager.BLL.Business
{
    public static class ClsInsuranceType
    {
        public static List<InsuranceType> SelectAll()
        {
            using (var db = Sys.NewDb())
            {
                return Data.Base.InsuranceType.Select(db);
            }
            
        }

        public static void Insert(InsuranceType capital)
        {
            using (var db = Sys.NewDb())
            {
                db.Insert<InsuranceType>(capital, EnumSaveMode.Requery);
            }
            
        }

        public static void Update(InsuranceType capital)
        {
            using (var db = Sys.NewDb())
            {
                db.Update<InsuranceType>(capital);
            }
            
        }

        public static InsuranceType SelectByPk(Int32 insTypId)
        {
            using (var db = Sys.NewDb())
            {
                return db.SelectSingle<InsuranceType>(string.Format("InsTypId={0}", insTypId));
            }
            
        }

        public static InsuranceType SelectByCode(string insTypCode)
        {
            using (var db = Sys.NewDb())
            {
                return db.SelectSingle<InsuranceType>(string.Format("InsTypCode='{0}'", insTypCode));
            }
            
        }

        public static int DeleteByPk(Int32 insTypId)
        {
            using (var db = Sys.NewDb())
            {
                return db.Delete<InsuranceType>(string.Format("InsTypId={0}", insTypId));
            }
            
        }
    }
}